﻿using System.Collections.Generic;
using System.Threading.Tasks;

namespace ESoft.Zookeeper
{
    public interface IZooKeeperService
    {
        /// <summary>
        /// 创建临时节点
        /// </summary>
        /// <param name="path"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        Task CreateEphemeralAsync(string path, byte[] data);

        /// <summary>
        /// 创建持久化节点
        /// </summary>
        /// <param name="path"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        Task CreatePersistentAsync(string path, byte[] data);

        /// <summary>
        /// 获取节点值
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        Task<IEnumerable<byte>> GetDataAsync(string path);

        /// <summary>
        /// 获取下级所有节点
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        Task<IEnumerable<string>> GetChildrenAsync(string path);

        /// <summary>
        /// 是否存在该节点
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        Task<bool> ExistsAsync(string path);

        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        Task DeleteAsync(string path);
    }
}
